/**
* @class
* Displays message inline to the DOM element it is atteched to when notified by ksg.ui.messenger that there is a message to display
* if the level provided is one of the levels listed in options.displayLevels.
* @meta-type jQuery widget
* @Depends ksg.baseWidget.js
*/
ksg.ui.widgets.InlineMessenger = {
	/**
	* The options used by this widget to control its behavior.
	* @field
	*/
	options: {
		/** Which message levels should this display show, all others are ignored. */
		displayLevels: [ksg.ui.messenger.levels.normal]
	},
	
	_create: function() { var self = this; var $this = this.element;
		
		ksg.ui.messenger.addObserver(function(msg) {
			if(self.options.displayLevels.indexOf(msg.level) != -1) {
				$this.html(msg.text);
				$this.effect("pulsate", {times:4}, "fast");
			}
		});
		ksg.App.bizProcMgr.addActionTriggerObserver({started: function() {
			$this.html("");
		}}).addBizObjSelectedObserver(function() {
			$this.html("");
		});		
	}
};
$.widget("ksg.inlineMessenger", ksg.ui.widgets.InlineMessenger);

ksg.ui.widgetMap["ksg-inlineMessenger"] = function ($el, options) {
	$el.inlineMessenger(options); 
};
